<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="{__STATIC_PATH}layuiadmin/layui/css/layui.css" media="all">
    <script src="{__STATIC_PATH}/layuiadmin/layui/layui.js"></script>
    <script>
        layui.config({
            base: '{__STATIC_PATH}layuiadmin/' //静态资源所在路径
        })
    </script>
</head>
<body>
<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
    <input type="hidden" name="id" value="<?php echo $arr_data_info['id'];?>">
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-inline">
            <input type="text" name="name" lay-verify="required" placeholder="请输入姓名" value="{$arr_data_info['name']}" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">权重</label>
        <div class="layui-input-inline">
            <input type="text" name="sort" lay-verify="number" placeholder="请输入权重" value="{$arr_data_info['sort']}" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">推广专员</label>
        <div class="layui-input-inline">
            <div id="admin_ids" name="admin_ids" ></div>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="admin-edit-submit" id="admin-edit-submit" value="确认修改">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="确认编辑">
    </div>
</div>
<script>
    layui.extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form','upload','layer','xmSelect'], function(){
        var $ = layui.$,form = layui.form,layer=layui.layer;
        var admin = layui.admin;
        var upload = layui.upload;
        var xmSelect = layui.xmSelect;
        var admin_ids = xmSelect.render({
            el: '#admin_ids',
            name:'admin_ids',
            initValue:[{$arr_data_info['admin_ids']}],
            data: {:json_encode($arr_tuiguangzhuanyuan_ids)}
    })
        var uploadInst = upload.render({
            elem: '#img'
            ,url: '/admin/file/uploadImage'
            ,field:'image'
            ,before: function(obj){
                layer.load();
            }
            ,done: function(res){
                layer.closeAll();
                if(res.code == 0){
                    $("#img_id").val(res.data.file_id);
                    $("#img_url").attr('src',res.data.url);
                    return layer.msg('上传成功');
                }else{
                    return layer.msg('上传失败');
                }
                //上传成功
            }
            ,error: function(){
                layer.closeAll();
                var demoText = $('#test-upload-demoText');
                demoText.html('<span style="color: #FF5722;">上传失败，请重新上传</span>');
            }
        });
        //监听提交
        form.on('submit(admin-edit-submit)', function(data){
            var field = data.field; //获取提交的字段
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            //提交 Ajax 成功后，关闭当前弹层并重载表格
            admin.req({
                url: "/admin/promotion/visitRecordEdit"
                ,type: "POST"
                ,data: field
                ,datatype:'json'
                ,success: function(res){
                    if (res.code == 0) {
                        layer.msg('修改成功',{time:500},function(){
                            parent.layui.table.reload('table-list'); //重载表格
                            parent.layer.close(index); //再执行关闭
                        });
                    }
                    else {
                        layer.msg(res.msg);
                    }
                }
            });
        });
    })
</script>
</body>
</html>